<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="hexinyang">
<title>变更合同类别</title>
<script language="javascript" type="text/javascript" src="../script/print.js"></script>
<script language="javascript" src="../script/common.js" type="text/javascript"></script>	
<script language="javascript" src="../script/card.js" type="text/javascript"></script>	
<script type="text/javascript">
	//页面加载方法	
	function load(){			
		Eui.showNavigation();
		setPages(["detview"]);
		CardMgnt.cardUser.show("companyUserView",null,CardMgnt.COMPANYUSER)
		Common.initDict(contractForm.newContractType,CardMgnt.getContractTypes(),"请选择");
	}
	
	//读主卡，查找单位客户帐户
	function readMasterCard(){
		var asn;
		try{
			getCard();
			asn = getAsn();
		}catch(e){showError(e.description);return;}
		$("companyform").asn.value = asn;
		DWR.call("mgntQueryService.findOkCompanyUser",asn,null,showCompanyUser)
	}
	
	//通过客户编号查找单位客户帐户
	function findCompanyUser(){
		var uniqueId = companyform.uniqueId.value;
		if (!uniqueId){
			showWarning("请输入或选择一个客户编号");return;
		}
		DWR.call("mgntQueryService.findOkCompanyUser",null,uniqueId,showCompanyUser)
	}
	
	function showCompanyUser(data){
		var companyUser = data.cardUser;
		if (!CardMgnt.checkCompanyLocation(companyUser)) return;
		CardMgnt.cardUser.showData("companyUserView",data,CardMgnt.COMPANYUSER)
		$("changeContractBtn").disabled = false;
	}
	
	//选择客户编号编号
	function selCardUser(){
		CardMgnt.selCardUser(function(v){
			companyform.uniqueId.value = v.uniqueId;
		},{cardUserType:CardUserType.COMPANY})
	}
	
	function changeContract(){
		if (!checkForm(contractForm)) return;
		var cl = contractForm.newContractType.value;
		var cardUser = CardMgnt.cardUser.get();
		DWR.call("customerService.changeContract",cardUser.id,cl,function(){
			showInformation("合同类别变更申请提交成功，等待审核");
			onCancel();
		});
	}
	
	//重置方法
	function onCancel(){
		$("changeContractBtn").disabled = true;
		CardMgnt.resetForm(CardMgnt.cardUser.formName);
		CardMgnt.resetForm(companyform);
		CardMgnt.resetForm(contractForm);
	}
	
</script>
</head>
<body onload="load()">
	<!--页面导航-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<div id="mainview">
		<div class="form">
			<form id="companyform" name="companyform">
				<div class="formTitle"><div class="l">查询单位客户</div><div class="r">
				</div></div>
				<table cellSpacing=0 cellPadding=4 width="100%" border=0 class="label6">
					<tr>
						<td>
							<label>单位主卡</label> <input type="text" name="asn" readonly class="readonly">
							<button onclick="readMasterCard()">读主卡</button>
						</td>
						<td>
							<label>客户编号</label> <input type="text" name="uniqueId"><a class="orga" href="#" onclick="selCardUser()">&nbsp;&nbsp;</a>
							<button onclick="findCompanyUser()">查 询</button>
						</td>
					</tr>	
				</table>
			</form>
		</div>
		<div class="form">
			<div id="companyUserView">
			</div>
			<form id="contractForm" name="contractForm">
				<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="col2 label6">
					<tr>										
						<td><label>新合同类别</label> <select name="newContractType" onblur="checkV(this,'',true)"><option></option></select> <span class="des">*</span></td>
						<td>&nbsp;</td>
					</tr>
				</table>
			</form>
		</div>
		<p>
			<button onclick="changeContract()" id="changeContractBtn" disabled>变更合同类别</button>
			<button onclick="onCancel()">重 置</button>
		</p>
	</div>
	
	<div id="detview" style="display:none;">
	</div>
</body>
</html>